package org.qiyu.live.im.core.server.common;

import io.netty.channel.ChannelHandlerContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: //todo
 * @Author: 张广焱
 * @Date: 2023-12-04 22:58
 */
public class ChannelHandlerContextCache {

    /**
     * @Description: 当前im服务时,对外暴露的ip端口
     * @Param:
     * @Author: 张广焱
     * @Date: 2023-12-10  08:33:44
     */
    private static String SERVER_IP_ADDRESS="";

    public static String getServerIpAddress() {
        return SERVER_IP_ADDRESS;
    }

    public static void setServerIpAddress(String serverIpAddress) {
        SERVER_IP_ADDRESS = serverIpAddress;
    }

    private static Map<Long, ChannelHandlerContext> channelHandlerContextCacheMap = new HashMap<>();

    /**
     * @Description: $description$
     * @Param: @param userId
     * @Author: 张广焱
     * @Date: 2023-12-04  23:02:32
     */
    public static ChannelHandlerContext get(Long userId) {
        return channelHandlerContextCacheMap.get(userId);
    }

    public static void put(Long userId, ChannelHandlerContext channelHandlerContext) {
        channelHandlerContextCacheMap.put(userId, channelHandlerContext);
    }

    public static void remove(Long userId) {
        channelHandlerContextCacheMap.remove(userId);
    }
}
